package com.wangxiang.sys.manage.controller;

import java.util.Arrays;
import java.util.Map;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.wangxiang.sys.manage.entity.AuthEntity;
import com.wangxiang.sys.manage.service.AuthService;
import com.wangxiang.common.utils.PageUtils;
import com.wangxiang.common.utils.R;



/**
 * @author wangxiang
 * @email 2293672863@qq.com
 * @date 2022-03-05 17:28:26
 */
@RestController
@RequestMapping("manage/auth")
public class AuthController {
    @Autowired
    private AuthService authService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = authService.queryPage(params);
        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") int id){
		AuthEntity auth = authService.getById(id);

        return R.ok().put("auth", auth);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody AuthEntity auth){
		authService.save(auth);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody AuthEntity auth){
		authService.updateById(auth);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody int[] ids){
		authService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
